{% extends "base.html" %}
{% block title %}
Contacts for {{event.name}}
{% endblock %}

{% block content %}
<h1>Contacts for <a href='/show?key={{event.key}}'>{{event.name}}</a></h1>
<h2>Current Contacts</h2>
<table border=1>

{% for contact in eventcontacts %}
    <tr><td> <a href='/viewcontact?key={{contact.key}}'>{{contact.name}} ({{contact.title}})</a> 
    {% if editable %}
    <td>
    <a href='/editcontact?key={{contact.key}}'>edit</a> <td> <a href='/removecontact?event={{event.key}}&contact={{contact.key}}'>delete</a>
    {% endif %}
    </td></tr>

{% endfor%}

{% if not eventcontacts %}
<tr><td>No contacts found.</td></tr>
{% endif %}

</table>

{% if editable %}

<h2>Add Existing Contacts</h2>
(add filter functionality!)<p>
<form action='/bindcontact' method=post>
<select multiple name=bindto>
{% for contact in globalcontacts %}
<option value={{contact.key}}>{{contact.name}}</option> 
{% endfor %}
</select>
<p>
<input type=hidden name=event value={{event.key}}>
<input type=Submit value='Add selected contacts'>
</form>

<h2>Add New Contact</h2>
<a href='/addcontact?event={{event.key}}'>Add New Contact</a>

{% endif %}
{% endblock %}
